"""
请求信息 | 模型
"""

from pydantic import BaseModel

import utils.enum_utils as enum
from my_typing import *
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    ListField,
    NormalField,
)


class RequestClient(BaseModel):
    """ 请求客户端 | Model """

    host: str = CharField(..., title="IP 地址", min_length=7, max_length=15)
    port: int = IntegerField(..., title="端口号", min_value=0, max_value=65535)


class RequestInfo(BaseModel):
    """ 请求信息 | Model """

    client: RequestClient = NormalField(..., title="请求客户端")
    body: dict = NormalField(..., title="请求体")
    form: dict = NormalField(..., title="表单参数")
    headers: dict = NormalField(..., title="请求头")
    params: dict = NormalField(..., title="请求参数")


class RequestRoute(BaseModel):
    """ 请求路由信息 | Model """

    dependencies: ListStr = ListField(default_factory=list, title="依赖项")
    deprecated: bool = NormalField(False, title="是否已废弃")
    include_in_schema: bool = NormalField(False, title="是否在 Swagger 中显示")
    method: enum.Method = CharField(..., title="请求方法")
    name: str = CharField("", title="路由名称")
    path: str = CharField(..., title="请求路径")
    path_format: str = CharField("", title="请求路径格式")
    path_regex: str = CharField("", title="路径正则表达式")
    request_model: StrOrNone = CharField(None, title="请求模型")
    response_model: StrOrNone = CharField(None, title="响应模型")
    summary: str = CharField("", title="路由描述")
    tags: list[enum.SwaggerTag] = ListField(default_factory=list, title="标签")
    unique_id: str = CharField("", title="唯一 ID")


class ResponseInfo(BaseModel):
    """ 响应信息 | Model """

    body: ListStr = NormalField(..., title="响应体")
    headers: dict = NormalField(..., title="响应头")
    media_type: StrOrNone = IntegerField(..., title="媒体类型")
    status_code: int = IntegerField(..., title="响应状态码")
